package org.wheres;

import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;

public class NoLocationDialog extends DialogFragment {
	
	public static NoLocationDialog newIstance(int title){
		NoLocationDialog dialog = new NoLocationDialog();
		Bundle b = new Bundle();
		b.putInt("title", title);
		dialog.setArguments(b);
		return dialog;
		
	}
	

	@Override
	public Dialog onCreateDialog(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		
		AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());

		builder.setMessage(R.string.NoPositionProviderDialogMessage)
				.setPositiveButton(R.string.OpenSettingsDialogButton, new DialogInterface.OnClickListener() {
					
					@Override
					public void onClick(DialogInterface dialog, int which) {
						startActivityForResult(new Intent(android.provider.Settings.ACTION_SETTINGS), 0);						
					}
				})
				.setNegativeButton(R.string.CancelDialogButton, new DialogInterface.OnClickListener() {
					
					@Override
					public void onClick(DialogInterface dialog, int which) {
						dialog.dismiss();
						
					}
				});
		 
		return builder.create();
		
	}
	
	
	
	public void showDialog(){
		
		NoLocationDialog locDialog = NoLocationDialog.newIstance(R.string.NoPositionProviderDialogTitle);
		locDialog.show(getFragmentManager(), "dialog");
		
	}

}
